# -*- coding: utf-8 -*-
# @Date   : 2021/07/15
# @File   : R74_CompanyStatusCheck_CF.py
# @Author : zhanghengfeng

'''eof
name:申请企业类别校验
code:R74_CompanyStatusCheck_CF
tableName:
columnName:
groups:出口信息模块
dependencies:CF_CQ_DSJ
type:常用指标
dataSourceType:
eof'''



null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']
        
def R74_CompanyStatusCheck_CF():
    try:
        baseInfo = CF_CQ_DSJ['body'].get('baseInfo')
        if baseInfo in null_type_list or baseInfo == []:
            return u'缺失值'
        elif isinstance(baseInfo,list) and len(baseInfo)== 1:
            #评级
            rank = baseInfo[0].get('rank')
            #企业名录资格
            isNameList = baseInfo[0].get('isNameList')
            #判断字符串是否是字母，且是单字母
            if rank.isalpha() and rank.isupper() and  isNameList.isalpha() and isNameList.isupper() and len(rank)== 1 and len(isNameList)== 1:
                if rank == "A" and isNameList == "Y":
                    return 1
                else:
                    return 0
            else:
                return u'缺失值'
        else:
            return u'缺失值'
    except:
        return u'缺失值'
    
result = R74_CompanyStatusCheck_CF()